﻿using Gumini.JulaDB.Engine;

namespace Gumini.JulaDB.Planner
{
    /// <summary>
    /// Represent an execution plan for a query.
    /// </summary>
    internal class QueryPlan
    {
        private readonly PlanNode _rootNode;

        public QueryPlan(PlanNode rootNode)
        {
            _rootNode = rootNode;
        }

        public RecordSet Execute()
        {
            return new RecordSet(_rootNode.Heading, _rootNode.Rows);
        }

        internal PlanNode RootNode
        {
            get { return _rootNode; }
        }

        public override string ToString()
        {
            return _rootNode.ToString();
        }
    }
}
